package demo.um.controller;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;

import demo.um.event.SayEvent;
import demo.um.interceptor.ParameterLogger;
import demo.um.quilifier.Goodbye;
import demo.um.quilifier.Hello;

@Named
@RequestScoped
public class EventController {

	private String name;
	private String message;
	private String log;

	@Inject
	@Hello
	private Event<SayEvent> helloEvent;

	@Inject
	@Goodbye
	private Event<SayEvent> goodbyeEvent;

	public void sayHello() {
		SayEvent hello = new SayEvent();
		hello.setName(name);

		helloEvent.fire(hello);
	}

	public void sayGoodbye() {
		SayEvent goodbye = new SayEvent();
		goodbye.setName(name);

		goodbyeEvent.fire(goodbye);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMessage() {
		return message;
	}

	@ParameterLogger
	public void setMessage(String message) {
		this.message = message;
	}

	public String getLog() {
		return log;
	}

	public void setLog(String log) {
		this.log = log;
	}

}
